{php include wl_template('common/header');}
<link rel="stylesheet" href="{TG_URL_ARES}components/light/light7.min.css">
<link rel="stylesheet" href="{TG_URL_ARES}components/weui/weui.css">
<link rel="stylesheet" href="{TG_URL_ARES}shaoniangong/css/common.css"/>
<link rel="stylesheet" href="{TG_URL_ARES}shaoniangong/css/myorder.css"/>
<script type='text/javascript' src='{TG_URL_ARES}components/light/light7.min.js' charset='utf-8'></script>
<script type="text/javascript" src="{MODULE_URL}app/resource/layer/layer.js" ></script>
<script type='text/javascript' src='{TG_URL_ARES}js/laytpl.js' charset='utf-8'></script>

<!--<link rel="stylesheet" href="{TG_URL_ARES}weiui/weui.min.css">-->
<!--<link rel="stylesheet" href="{TG_URL_ARES}weiui/jquery-weui.min.css">-->
<!--<link rel="stylesheet" href="{TG_URL_ARES}shaoniangong/css/aliicon/font.css"/>-->
<!--<link rel="stylesheet" href="{TG_URL_ARES}shaoniangong/css/swiper.min.css"/>-->
<!--<link rel="stylesheet" href="{TG_URL_ARES}shaoniangong/css/common.css"/>-->
<!--<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>-->
<!--<script src="{TG_URL_ARES}shaoniangong/js/cartFly.js"></script>-->
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-weui/1.0.1/js/jquery-weui.min.js"></script>-->
<!--<script src="{TG_URL_ARES}shaoniangong/js/swiper.min.js"></script>-->
<!--<script src="//cdn.bootcss.com/jquery-weui/1.0.1/js/city-picker.min.js"></script>-->
<style>
    .m-cart .empty a,.link-ding-header div:first-child{color: #ff5c67;opacity: 0.93}
    .link-ding {width:96%;margin:auto;height:auto;background-color:white;border-radius:5px;margin-bottom:6px; }
    .link-ding-header{width:90%;position:relative;left:5%;height:40px;border-bottom:1px solid #ccc;}
    .link-ding-header div:first-child{position:absolute;top:12.5px;height:22.5px;line-height:22.5px;color:#6fbfd8;font-size:14px;}
    .link-ding-header div:nth-child(2) {position:absolute;top:35px;height:15px;line-height:15px;color:#888;font-size:10px;}
    .link-ding-header div:nth-child(3) {position:absolute;top:45px;height:15px;line-height:15px;color:#888;font-size:10px;}
    .link-ding-header span{background-color:hsl(36, 100%, 49%);display:block;width:50px;height:20px;top:12.5px;right:-5px;border-radius:5px;color:white;font-size:12px;line-height:20px;position:absolute;text-align:center;}
    .link-ding-body {width:90%;margin-left:5%;margin-top:5px;font-size:12px;color:#333;}
    .link-ding-body>div {position:relative;margin-bottom:10px;}
    .link-ding-body>div div:last-child{position:absolute;right:20%;top:0px;color:#6fbfd8;bottom:0px;margin:auto;}
    .link-ding-body>div div:nth-child(3) {position:absolute;right:40%;top:0px;bottom:0px;margin:auto;}
    .link-body-feight {position:relative;margin-top:10px;color:#999;padding: 5px 0;}
    .link-total{position:absolute;right:0px!important;top:0px;color:#999!important;}
    .link-ding-footer {
        border-top:1px solid #ccc;
        width: 96%;
        margin-left: 2%;
        color: white;
        border-top: 1px solid #ccc;
        padding-bottom: 1px;
        background: #fff;
        margin-top: -5px;
        margin-bottom: 5px;
        height: 50px;
    }
    .link-ding-footer>div:first-child {margin-top:10px;margin-bottom:10px;margin-left:10%;width:30%;height:27.5px;line-height:27.5px;text-align:center;font-size:12px;border-radius:5px;color:#999;border:1px solid #999;}
    .link-ding-footer>div:last-child {    left: 60%;
        width: 30%;
        height: 27.5px;
        line-height: 27.5px;
        text-align: center;
        top: -5px;
        font-size: 12px;
        border-radius: 5px;
        background-color: #6fbfd8;
        display: block;
        position: absolute;}
    .buttons-tab .button.active{
        color: #ff5c67;
        border-color: #ff5c67;
        opacity: 0.93;
    }
    /*//底部导航栏*/
    #footer{
        z-index: 100000;
    }
    /*我的预约*/
    #footer li:nth-child(4),.link-ding-header div:first-child,.link-ding-body>div div:last-child>span,.link-ding-body>div div:last-child{
        color: #ff5c67 !important;
        opacity: 0.93;
    }
    .m-cart .empty a{
        color: #ff5c67;
        opacity: 0.93;
    }
    .link-ding-footer>a,.link-ding-footer>div:last-child{
        background-color: #ff5c67 !important;
        opacity: 0.93;
    }
    .link-ding-body>div div.link-total{
        color:#999 !important;
    }
    .m-cart .empty{
        text-align: center;
        padding-top: 100px;
    }
    .pingJia{
        position: absolute;
        right: -145%;
        top: 0;
        color: #fff;
        background: #ff5c67;
        padding: 0 10px;
        border-radius: 3px;
    }
</style>
<div id="footer">{php include wl_template('common/footer');}</div>
<div class="page-group">

    <div class="page page-current" id="page-order-list">
        <div class="buttons-tab" style="z-index: 100;">
            <a href="#tab1" class="tab-link button {if $status==''}active{/if}" id="">全部</a>
            <!--   <a href="#tab2" class="tab-link button {if $status=='0'}active{/if}" id="0">待付款</a>-->
            <a href="#tab3" class="tab-link button {if $status=='8'}active{/if}" id="8">未参加</a>
            <!-- <a href="#tab4" class="tab-link button {if $status=='2'}active{/if}" id="2">待收货</a> -->
            <a href="#tab5" class="tab-link button {if $status=='3'}active{/if}" id="3">已参加</a>
            <!-- <a href="#tab6" class="tab-link button {if $status=='11'}active{/if}" id="11" >售后</a> -->
        </div>
        <div class="content infinite-scroll native-scroll" data-distance="10">
            <div class="tabs" style="padding-top: 2.8rem;">
            </div>

            <div class="list" style="background-color: #efeff4;margin-bottom: 60px;">
                <div class="loading_more" style="padding-top: 10px;display: none;font-size:14px;text-align: center;margin-bottom: 5px"><span class="loading"><i class="icon_load"></i>正在玩命的加载中......</span></div>
                <!--<div class="error">加载失败，点击重新加载</div>-->
                <div class="noData" style="text-align:center;;font-size:14px;color:#c3c3c3;display: none">全部数据加载完毕</div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="orderlist">
    
    {{# for(var i = 0, len = d.list.length; i < len; i++){ }}
    
    <div class="link-ding">
        <div class="link-ding-header">
            <div>预约号:{{ d.list[i].orderno }}</div>
            <!--<div>下单时间：2016-06-21 10:35:23</div>
            <div>收货地址：21日下午自提（中山市）</div>-->
            <span class="yyzt">{{ d.list[i].statusname }}</span>
        </div>
        <div class="link-ding-body">


            {{# for(var j = 0, lenn = d.list[i].goods.length; j < lenn; j++){ }}
            <div>
                <div style="width: 150px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">{{d.list[i].goods[j].gname}}</div>
                <span>{{# if(d.list[i].goods[j].item.length>0){ }}规格：{{ d.list[i].goods[j].item }}{{# } }}</span>
                <div>x{{ d.list[i].goods[j].num }}</div>
                <div>￥{{ d.list[i].goods[j].oprice }}   <p data-id="{{ d.list[i].goods[j].id}}" class="pingJia" style="{{# if(d.list[i].goods[j].check_status=='0'){ }}display:none;{{# } }}">评价</p></div>
            </div>
            {{# } }}


            <!-- {{# if(d.list[i].selltype==4){ }}<div>返还：￥{{ d.list[i].refund }}元</div>{{# } }} -->
            <div>活动时间：{{ d.list[i].startTimeStr }} 至 {{ d.list[i].endTimeStr }}</div>  
            <div class="link-body-feight" style="position: relative;margin-bottom: 25px">
                <!--<div style="color:#999">运费：￥{{ d.list[i].freight }}元</div>-->
                <div style="color:#999"></div>
                <div class="link-total">总计消费：<span class="ed5CO" style="color:#6fbfd8;font-size:1.5em;">￥{{ d.list[i].realprice }}</span></div>
            </div>
        </div>
        <div class="link-ding-footer" style="position:relative;">

            {{# if(d.list[i].status == 0){ }}
            <div class="weui_btn weui_btn_mini weui_btn_blue field-btn-gray topay" style="color: #fff"  oid="{{ d.list[i].orderno }}">去支付</div>
            {{# } else if(d.list[i].realprice == 0 && d.list[i].status == 8 && d.list[i].cancel_status) { }}
            <div class="weui_btn weui_btn_mini weui_btn_tran freecancel" style="display: inline-block;" oid="{{ d.list[i].orderno }}">取消预约</div>
            {{# } }}
            {{# if( d.list[i].attend == 1 && d.list[i].status != 10){ }}
            <div class="weui_btn weui_btn_mini jspy" style="display: inline-block;margin-bottom:10px;" data-id="{{d.list[i].id}}" oid="{{ d.list[i].orderno }}"><a style="position: relative;z-index: 100;" >教师评语</a></div>
            <a href="{{ d.list[i].a }}" style="float:right;display:inline-block;margin-top:10px;margin-bottom:10px;color:white!important;width:30%;height:27.5px;line-height:27.5px;text-align:center;font-size:12px;border-radius:5px;color:#999;" class="weui_btn weui_btn_mini weui_btn_blue field-btn-gray external">预约详情1学生上学啊111</a>
            {{# } }}
        </div>
    </div>
    {{# } }}
</script>
<div class="popup popup-qrcode">
    <div class="content" style="background: #eee;">
        <div class="list-block cards-list">
            <ul>
                <li class="card" style="border-radius: .2rem;">
                    <div class="card-header"><h3 class="font-size-14">核销预约活动凭证</h3></div>
                    <div class="card-content">
                        <div class="card-content-inner">
                            <div class="voucher-code">
                                <p>提货码：{$order['hexiaoma']}</p>
                                <p>
                                    <img src="{TG_URL}data/qrcode/{$_W['uniacid']}/{$order['orderno']}.png" alt="">
                                </p>
                            </div>
                            <div class="voucher-address font-size-14">
                                <p>提货地址：{$order['address']}</p>
                                <p>到店时间：尽快到店提货</p>
                            </div>
                            <div class="voucher-goods-info font-size-14">
                                <p>活动信息：{$goods['gname']} </p>
                                <p>实付金额：{$order['pay_price']}元</p>
                            </div>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
        <div class="weui_btn_area">
            <a class="weui_btn weui_btn_warn close-popup">关闭</a>
        </div>
    </div>
    <script type="text/javascript">
        var arr = new Array(1,2,3,8);
        function contains(arr, obj) {
            var i = arr.length;
            while (i--) {
                if (arr[i] === obj) {
                    return true;
                }
            }
            return false;
        }
        function cutString(str, len) {

            //length属性读出来的汉字长度为1

            if(str.length*2 <= len) {

                return str;

            }

            var strlen = 0;

            var s = "";

            for(var i = 0;i < str.length; i++) {

                s = s + str.charAt(i);

                if (str.charCodeAt(i) > 128) {

                    strlen = strlen + 2;

                    if(strlen >= len){

                        return s.substring(0,s.length-1) + "...";

                    }

                } else {

                    strlen = strlen + 1;

                    if(strlen >= len){

                        return s.substring(0,s.length-2) + "...";

                    }

                }

            }

            return s;

        }

        if (document.getElementById('qrcode')){
            document.getElementById('qrcode').onclick=function ( ev ) {
            }
        }
        $('.buttons-tab').find('a').click(function(){
            var status = $(this).attr('id');
            $(this).addClass('active').siblings().removeClass('active');
            location.href = "{php echo app_url('order/order/list')}&status="+status;
        });
        //取消预约
        $(document).on('click','.cancel',function(){
            var orderno = $(this).attr('oid');
            $.confirm('确认取消预约？',
                    function () {
                        $.post("{php echo app_url('order/order/cancel')}",{orderno:orderno},function(d){
                            if(d.status == 1){
                                $.toast('预约取消成功！');
                                setTimeout(function () {
                                    location.href = "{php echo app_url('order/order/list')}";
                                }, 1000);
                            }else{
                                $.toast(d.result);
                            }
                        },"json");
                    }
            );
        });
        // 免费订单取消
        $(document).on('click','.freecancel',function () {
            var orderno = $(this).attr('oid');
            $.confirm('确认取消预约？',
                function(){
                    $.post(order_cancel,{orderno:orderno},function (res) {
                        if(res.status == 1) {
                            $.toast('预约取消成功！');
                            setTimeout(function () {
                                location.href = "{php echo app_url('order/order/list')}";
                            }, 1000);
                        }else{
                            $.toast(res.result);
                        }
                    },"json")
                })
        })
        //支付订单
        $(document).on('click','.topay',function(){
            var orderno = $(this).attr('oid');
            $.get(before_pay_checksng,{orderno:orderno},function(res) {
                var data = JSON.parse(res);
                if(data.boom == 1) {
                    $.toast('库存不足');
                    setTimeout(function () {
                      window.location.href = window.location.href;  
                    },1500)
                    return;
                }
                if (data.status == 0) {
                    var paytype = 'wechat';
                    $.post(paycash, {orderno: orderno, paytype: paytype}, function (m) {
                        if (!m.errno) {
                            m.data.timeStamp = String(m.data.timeStamp);
                            WeixinJSBridge.invoke('getBrandWCPayRequest', {
                                'appId': m.data.appid ? m.data.appid : m.data.appId,
                                'timeStamp': m.data.timeStamp,
                                'nonceStr': m.data.nonceStr,
                                'package': m.data.package,
                                'signType': m.data.signType,
                                'paySign': m.data.paySign
                            }, function (res) {
                                if (res.err_msg == 'get_brand_wcpay_request:ok') {
                                    location.href = paycash + "&orderno=" + orderno + "&paytype=" + paytype + "&done=1";
                                } else {
                                    $.toast("已取消支付", 'cancel');
                                }
                            });
                        }
                    }, "json");
                }else if (data.status == 1) {
                    $.toast('该项目预约时间已满，请重新下单', 'cancel');
                    location.href = indexUrl;
                    return false;
                }
            })
        });

        $(function () {
            'use strict';
            $(document).on("pageInit", "#page-order-list", function(e, id, page) {

                var loading = false;
                var thispagesize = 10;
                var thispagesizemax = 0;
                var thispage = 1;
                function addItems(thispage, thispagesize) {
                    var status = "{$status}";
                    var attend = "{$attend}";
                    if(status === '8') {
                        attend = '1';
                    }else {
                        attend = '';
                    }
                    var ajaxurl = "{php echo app_url('order/order/sng_ajax')}"+"&page="+thispage+"&pagesize="+thispagesize+"&status="+status+"&attend="+attend;
                    $.ajax({
                        type: "POST",
                        url: ajaxurl,
                        dataType: 'json',
                        beforeSend: function(XMLHttpRequest) {

                        },
                        success: function(data) {
                            console.log(data);
                            thispagesizemax = data.total;
                            if (data.list.length > 0) {
//                                for(var i = 0; i < data.list.length;i++){
//                                    if(data.list[i].attend == '1'){
                                        var gettpl = document.getElementById('orderlist').innerHTML;
                                        laytpl(gettpl).render(data, function(html){
                                            $(".tabs").append(html);
                                        });
//                                    }
//                                }
                            } else if (thispagesizemax > 0) {
                                $(".loading_more").remove();
                                $('.noData').show();
                            } else {
                                var html = '<div class="m-cart" id="s"><div class="empty" id="pro-view-6">暂无预约数据，<a href="{php echo app_url('goods/index')}" class="external">马上去逛逛~</a></div></div>';
                                $(".tabs").append(html);
                            }      
                            for(var i=0;i<$('.yyzt').length;i++){
                                if($('.yyzt').eq(i).html()=="已完成"){
                                    $('.jspy').eq(i).css("display","inline-block")
                                }else{
                                    $('.jspy').eq(i).hide()                                
                                }
                            }                                                                                                                        
                        },
                        error:function(){
                            $('.error').show();
                        }
                    });
                }
                addItems(thispage,thispagesize);

                $(page).on('infinite', function() {
                    if (loading) return;
                    loading = true;
                    $(".loading_more").show();
                    setTimeout(function() {
                        loading = false;
                        thispage++;
                        addItems(thispage,thispagesize);
                        $(".loading_more").hide();
                        $.refreshScroller();
                    }, 1000);
                });
            });
            $.init(); 
        });
        $('.tabs').on('click', '.jspy', function() {
            location.href="{php echo app_url('order/order/detail-notice')}id="+$(this).attr('data-id')
        })

        $('.tabs').on('click','.pingJia',function(){
            location.href="{php echo app_url('goods/judgment_list',array('op' => 'judgment_detail'))}"+'&id='+$(this).attr('data-id');
        })
    </script>
    </div>
</body>
<script src="{TG_URL_ARES}shaoniangong/js/common.js"></script>